﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ServiceDeskInterop;
using ServiceDesk.Model;
using ServiceDesk.DAL;
using System.ServiceModel;



namespace ServiceDesk.Service
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
    public class ServiceDeskServiceImplementation : IServiceDeskService
    {
        public ServiceDeskServiceImplementation()
        {
            SessionModel = new SessionModel(SessionFactory.SessionFactory);
        }
        private readonly SessionModel SessionModel;

        public static ServiceDeskSessionFactory SessionFactory;// TODO: нужно обязательно убрать из статического и передавать через констуктор
                                                            // 


        public string Ping()
        {
            return "Ping";
        }

        
        public LoginDTO Login(string login, string password)
        {

            return SessionModel.LogIn(login, password);
        }
        public IEnumerable<TaskDTO> ListTasks()
        {
            return
                SessionModel.ListTasks();
        }

        public IEnumerable<UserDTO> ListUsers()
        {
            return
                SessionModel.ListUsers();
        }
        public UserDTO AddUser(string login, string password, RoleDTO role)
        {
            return
                SessionModel.AddUser(login, password, role);
        }
        public bool RemoveUser(Guid userGuid)
        {
            return
                SessionModel.RemoveUser(userGuid);
        }
        public void SetTaskState(Guid taskGuid, TaskStateDTO taskState)
        {
            SessionModel.SetTaskState(taskGuid, taskState);
        }
        public void Assign(Guid taskGuid, Guid userGuid)
        {
            SessionModel.Assign(taskGuid, userGuid);
        }

    }
}
